/*
 * Created on May 11, 2005
 *
 * Copyright 2005 Pau Rodriguez-Estivill <prodrigestivill@yahoo.es>
 *
 * This software is licensed under the GNU General Public License.
 * See http://www.gnu.org/copyleft/gpl.html for details.
 */

package ist.mus.gui;

import java.awt.Frame;

import javax.swing.SpinnerNumberModel;

/**
 * @author Pau Rodriguez-Estivill
 */
public class JMusLogin extends javax.swing.JDialog {

    private final static String[] servers = { "jabberes.org", "jabber.upc.es",
            "bulma.net", "jabber-hispano.org", "jabber.madridwireless.net",
            "mi.uji.es", "jabber.gulo.org", "jabber.redlibre.org", "seunet.org" };

    public int func = 0;

    /** Creates new form JMusLogin */
    public JMusLogin(Frame arg0, boolean arg1) {
        super(arg0, "Conectarse/Loginar", arg1);
        initComponents();
        func = 0;
        login.addActionListener(new HandlerActionAdapter(this));
        login.setActionCommand("login");
        cancel.addActionListener(new HandlerActionAdapter(this));
        cancel.setActionCommand("close");
        setVisible(true);
    }

    public void close_ActionPerformed() {
        dispose();
    }

    public void login_ActionPerformed() {
        func = 1;
        dispose();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        server = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        username = new javax.swing.JTextField();
        passwd = new javax.swing.JPasswordField();
        jLabel4 = new javax.swing.JLabel();
        port = new javax.swing.JSpinner();
        sslchk = new javax.swing.JCheckBox();
        login = new javax.swing.JButton();
        cancel = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setResizable(false);
        jPanel1.setLayout(null);

        jPanel1.setPreferredSize(new java.awt.Dimension(290, 190));
        jLabel1.setText("Servidor Jabber");
        jPanel1.add(jLabel1);
        jLabel1.setBounds(20, 22, 95, 15);

        jLabel2.setText("Usuario");
        jPanel1.add(jLabel2);
        jLabel2.setBounds(20, 82, 48, 15);

        server.setEditable(true);
        server.setModel(new javax.swing.DefaultComboBoxModel(servers));
        server
                .setToolTipText("Para registrarse debe usar su pagina web o un cliente de jabber.");
        server.setPreferredSize(new java.awt.Dimension(130, 24));
        jPanel1.add(server);
        server.setBounds(130, 22, 130, 24);

        jLabel3.setText("Contrasena");
        jPanel1.add(jLabel3);
        jLabel3.setBounds(20, 112, 71, 15);

        jPanel1.add(username);
        username.setBounds(130, 82, 130, 19);

        jPanel1.add(passwd);
        passwd.setBounds(130, 112, 130, 19);

        jLabel4.setText("Puerto");
        jPanel1.add(jLabel4);
        jLabel4.setBounds(20, 52, 40, 15);

        port.setModel(new SpinnerNumberModel(5222, 1, 65535, 1));
        jPanel1.add(port);
        port.setBounds(130, 52, 70, 20);

        sslchk.setText("SSL");
        jPanel1.add(sslchk);
        sslchk.setBounds(220, 52, 46, 23);

        login.setText("Login");
        jPanel1.add(login);
        login.setBounds(30, 150, 88, 25);

        cancel.setText("Cancelar");
        cancel.setDefaultCapable(false);
        jPanel1.add(cancel);
        cancel.setBounds(160, 150, 88, 25);

        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);

        pack();
    }//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    javax.swing.JButton cancel;

    private javax.swing.JLabel jLabel1;

    private javax.swing.JLabel jLabel2;

    private javax.swing.JLabel jLabel3;

    private javax.swing.JLabel jLabel4;

    private javax.swing.JPanel jPanel1;

    javax.swing.JButton login;

    public javax.swing.JPasswordField passwd;

    public javax.swing.JSpinner port;

    public javax.swing.JComboBox server;

    public javax.swing.JCheckBox sslchk;

    public javax.swing.JTextField username;
    // End of variables declaration//GEN-END:variables

}
